﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using Happy.Web.Mvc;
using Happy.Cms.Query.Articles;
using Happy.Cms.Application.Articles;
using Ciep.WebSite.Models;

namespace Ciep.WebSite.Controllers
{
    public class AboutController : CiepController
    {
        private static readonly string _CategoryName = "关于我们";

        //
        // GET: /About/

        public ActionResult Index(Guid? id)
        {
            this.SetCommonDataToViewBag();

            var articles = this.Service<ArticleQueryService>()
                .FindByCategoryName(_CategoryName);
            var current = articles.FirstOrDefault(x => !id.HasValue || x.Id == id.Value);
            current = current ?? new ArticleView();

            return View(new GroupArticles
            {
                Articles = articles,
                Current = current
            });
        }

        protected override string Title
        {
            get { return _CategoryName; }
        }

        protected override int MenuIndex
        {
            get { return 6; }
        }
    }
}
